Skip to content

Fix lazynpm command execution and npm link handling for modern Go/npm versions#19

Open
BoxThatBeat wants to merge 1 commit into
jesseduffield:masterfrom
BoxThatBeat:master
Open

Fix lazynpm command execution and npm link handling for modern Go/npm versions#19
BoxThatBeat wants to merge 1 commit into
jesseduffield:masterfrom
BoxThatBeat:master

Conversation

@BoxThatBeat
Copy link
Copy Markdown

Summary

  • Fix PTY command execution broken by Go 1.20+ Ctty behavior change in vendored creack/pty
  • Fix LinkedGlobally detection failing due to relative vs absolute symlink path comparison
  • Fix (linked) status not showing for packages linked via npm link (not in package.json)
  • Update npm unlink to npm rm -g for global unlink (npm v7+ changed unlink semantics)
  • Show actionable error when attempting to link a package that isn't globally linked yet

Details

No commands worked at all — vendor/github.com/creack/pty/run.go set SysProcAttr.Ctty to a parent-process FD. Go 1.20 requires Ctty to be valid in the child process. Every PTY-spawned command (npm install, npm link, npm run build, etc.) silently failed with Setctty set but Ctty not valid in child. Fixed by passing the tty as an ExtraFiles entry and setting Ctty to its child FD index.

LinkedGlobally was always false — IsLinked() compared the raw os.Readlink result (a relative path like ../../../../../home/...) against an absolute package path. They never matched. Fixed by resolving relative symlink targets to absolute paths before comparison.

"(linked)" text never appeared — linkPathMap() only checked dependencies declared in package.json. npm link creates a symlink in node_modules/ without modifying package.json, so the link was invisible. Fixed by scanning node_modules/ (including scoped @org/ dirs) for actual symlinks on disk.

Global unlink was broken on npm v7+ — handleGlobalLinkPackage used bare npm unlink, which became an alias for npm uninstall (local) in npm v7. Changed to npm rm -g .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant